package cn.atzxc.qy.controller;

import cn.atzxc.qy.utils.OssUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * Description
 * User:
 * Date:
 * Time:
 */
@RestController
@RequestMapping("/fileoss")
public class OssController {

    //上传图片
    @PostMapping("/upload")
    public String uploadFile(MultipartFile file) throws IOException {
        System.out.println("进来了55"+file);
        String fileName = OssUtil.upload(file.getOriginalFilename(), file.getInputStream());
        System.out.println("000000"+fileName);
        JSONObject object = new JSONObject();
        return fileName;
    }
}
